Version 0.10.0 #23
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Release | |
on: | |
push: | |
tags: | |
- v*.*.* | |
jobs: | |
release: | |
name: Build release artifacts | |
runs-on: ${{ matrix.os }} | |
strategy: | |
matrix: | |
include: | |
- os: macos-latest | |
target: x86_64-apple-darwin | |
- os: macos-latest | |
target: aarch64-apple-darwin | |
- os: ubuntu-latest | |
target: x86_64-unknown-linux-gnu | |
- os: ubuntu-latest | |
target: x86_64-unknown-linux-musl | |
- os: ubuntu-latest | |
target: aarch64-unknown-linux-gnu | |
- os: ubuntu-latest | |
target: aarch64-unknown-linux-musl | |
- os: windows-latest | |
target: x86_64-pc-windows-msvc | |
- os: windows-latest | |
target: aarch64-pc-windows-msvc | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
- name: Setup Rust | |
run: rustup target add ${{ matrix.target }} | |
- name: Install additional toolchains | |
if: ${{ matrix.os == 'ubuntu-latest' }} | |
run: | | |
set -x | |
case "${{ matrix.target }}" in | |
x86_64-unknown-linux-gnu) | |
;; | |
x86_64-unknown-linux-musl) | |
sudo apt-get update | |
sudo apt-get install -y musl-tools | |
;; | |
aarch64-unknown-linux-gnu) | |
sudo apt-get update | |
sudo apt-get install -y gcc-aarch64-linux-gnu | |
echo '[target.aarch64-unknown-linux-gnu]' >> .cargo/config | |
echo 'linker = "aarch64-linux-gnu-gcc"' >> .cargo/config | |
;; | |
aarch64-unknown-linux-musl) | |
mkdir -p $HOME/.local | |
curl -o /tmp/musl.tgz https://musl.cc/aarch64-linux-musl-cross.tgz | |
tar -xzf /tmp/musl.tgz -C $HOME/.local | |
echo "$HOME/.local/aarch64-linux-musl-cross/bin" >> $GITHUB_PATH | |
echo '[target.aarch64-unknown-linux-musl]' >> .cargo/config | |
echo 'linker = "aarch64-linux-musl-gcc"' >> .cargo/config | |
;; | |
esac | |
- name: Configure cache | |
uses: actions/cache@v3 | |
with: | |
path: | | |
~/.cargo/bin/ | |
~/.cargo/registry/index/ | |
~/.cargo/registry/cache/ | |
~/.cargo/git/db/ | |
target/ | |
key: release-${{ runner.os }}-cargo-${{ matrix.target }}-${{ hashFiles('**/Cargo.lock') }} | |
- name: Build | |
run: cargo build --release --locked --target ${{ matrix.target }} | |
- name: Strip binary | |
if: ${{ matrix.os != 'windows-latest' }} | |
run: | | |
set -x | |
strip="strip" | |
case "${{ matrix.target }}" in | |
x86_64-unknown-linux-gnu) | |
;; | |
x86_64-unknown-linux-musl) | |
;; | |
aarch64-unknown-linux-gnu) | |
strip=aarch64-linux-gnu-strip | |
;; | |
aarch64-unknown-linux-musl) | |
strip=aarch64-linux-musl-strip | |
;; | |
esac | |
${strip} target/${{ matrix.target }}/release/grcov | |
- name: Package (unix) | |
if: ${{ matrix.os != 'windows-latest' }} | |
run: | | |
set -x | |
rm -rf target/dist | |
mkdir target/dist | |
cd target/${{ matrix.target }}/release | |
tar cjf ../../dist/grcov-${{ matrix.target }}.tar.bz2 grcov | |
- name: Package (windows) | |
if: ${{ matrix.os == 'windows-latest' }} | |
run: | | |
if (Test-Path target/dist) { rm -Recurse -Force target/dist } | |
mkdir target/dist | |
cd target/${{ matrix.target }}/release | |
7z a ../../dist/grcov-${{ matrix.target }}.zip grcov.exe | |
- name: Upload archive | |
uses: actions/upload-artifact@v4 | |
with: | |
name: artifact-${{ matrix.target }} | |
path: target/dist/* | |
publish: | |
name: Publish release | |
runs-on: ubuntu-latest | |
needs: [release] | |
steps: | |
- name: Download artifacts | |
uses: actions/download-artifact@v4 | |
- name: Create checksums | |
run: | | |
set -x | |
for dir in $(pwd)/artifact-*; do | |
cd $dir | |
sha256sum -b * >> ~/checksums.sha256 | |
done | |
- name: Create release | |
id: release | |
run: | | |
set -x | |
curl --request POST \ | |
--url https://api.github.com/repos/${{ github.repository }}/releases \ | |
--header "Accept: application/vnd.github.v3+json" \ | |
--header "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \ | |
--header "Content-Type: application/json" \ | |
--data '{ | |
"tag_name": "${{ github.ref_name }}", | |
"name": "Release ${{ github.ref_name }}", | |
"body": "Release ${{ github.ref_name }}", | |
"draft": true | |
}' \ | |
--fail > release.json | |
id=$(jq .id release.json) | |
echo "id=$id" >> $GITHUB_OUTPUT | |
- name: Upload artifacts | |
run: | | |
set -x | |
for file in $(ls artifact-*/*.{tar.bz2,zip}) ~/checksums.sha256; do | |
filename=$(basename -- "$file") | |
extension="${filename#*.}" | |
type="text/plain" | |
case $extension in | |
zip) | |
type="application/zip" | |
;; | |
tar.bz2) | |
type="application/x-bzip2" | |
;; | |
esac | |
curl --request POST \ | |
--url https://uploads.github.com/repos/${{ github.repository }}/releases/${{ steps.release.outputs.id }}/assets?name=${filename} \ | |
--header "Accept: application/vnd.github.v3+json" \ | |
--header "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \ | |
--header "Content-Type: ${type}" \ | |
--data-binary "@${file}" \ | |
--fail | |
done |